package com.jy.api.controller.admin;

import com.jy.api.service.BillRuleService;
import com.jy.api.signUpReq.admin.BillRuleReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xiaohua on 2019/4/28.
 */
@RequestMapping(value = "v1/admin/", produces = "application/json;charset=utf-8")
@RestController
public class BillRuleController {

    @Autowired
    private BillRuleService ruleService;


    @GetMapping("rule-list")
    public ResponseEntity ruleList(@RequestParam("storeId") String storeId) {
        return ResponseEntity.ok(ruleService.findRuleList(storeId));
    }

    @PostMapping("rule-remove")
    public ResponseEntity ruleRemove(@RequestBody BillRuleReq req) {
        ruleService.deleteById(req.getId());
        return ResponseEntity.ok().build();
    }

    @PostMapping("rule-merge")
    public ResponseEntity mergeRemove(@RequestBody BillRuleReq req) {
        return ResponseEntity.ok(ruleService.updateOrSave(req));
    }


}
